package org.dromara.datacheck.mytest;

import java.util.*;

public class NestedDataStructureExample {

    public static void main(String[] args) {
        // 创建最外层的 List
        List<Map<String, List<Map<String, List<Map<String, Integer>>>>>> purchaseProcess = new ArrayList<>();

        // 创建最内层的数据
        Map<String, Integer> innermostMap1 = new HashMap<>();
        innermostMap1.put("item1", 10);
        innermostMap1.put("item2", 20);

        Map<String, Integer> innermostMap2 = new HashMap<>();
        innermostMap2.put("item3", 30);
        innermostMap2.put("item4", 40);

        // 创建第二层的数据
        List<Map<String, Integer>> secondInnerList1 = new ArrayList<>();
        secondInnerList1.add(innermostMap1);
        secondInnerList1.add(innermostMap2);

        List<Map<String, Integer>> secondInnerList2 = new ArrayList<>();
        secondInnerList2.add(innermostMap1);
        secondInnerList2.add(innermostMap2);

        // 创建第三层的数据
        Map<String, List<Map<String, Integer>>> thirdInnerMap1 = new HashMap<>();
        thirdInnerMap1.put("step1", secondInnerList1);
        thirdInnerMap1.put("step2", secondInnerList2);

        Map<String, List<Map<String, Integer>>> thirdInnerMap2 = new HashMap<>();
        thirdInnerMap2.put("step3", secondInnerList1);
        thirdInnerMap2.put("step4", secondInnerList2);

        // 创建最外层的数据
        Map<String, List<Map<String, List<Map<String, Integer>>>>> outerMap1 = new HashMap<>();
        outerMap1.put("process1", new ArrayList<>(Arrays.asList(thirdInnerMap1, thirdInnerMap2)));

        Map<String, List<Map<String, List<Map<String, Integer>>>>> outerMap2 = new HashMap<>();
        outerMap2.put("process2", new ArrayList<>(Arrays.asList(thirdInnerMap1, thirdInnerMap2)));

        // 添加到最外层的 List
        purchaseProcess.add(outerMap1);
        purchaseProcess.add(outerMap2);

        // 打印结果
        printNestedData(purchaseProcess);
    }

    private static void printNestedData(List<Map<String, List<Map<String, List<Map<String, Integer>>>>>> data) {
        for (Map<String, List<Map<String, List<Map<String, Integer>>>>> process : data) {
            for (Map.Entry<String, List<Map<String, List<Map<String, Integer>>>>> entry : process.entrySet()) {
                System.out.println("Process: " + entry.getKey());
                for (Map<String, List<Map<String, Integer>>> step : entry.getValue()) {
                    for (Map.Entry<String, List<Map<String, Integer>>> stepEntry : step.entrySet()) {
                        System.out.println("  Step: " + stepEntry.getKey());
                        for (Map<String, Integer> item : stepEntry.getValue()) {
                            for (Map.Entry<String, Integer> itemEntry : item.entrySet()) {
                                System.out.println("    Item: " + itemEntry.getKey() + " - Quantity: " + itemEntry.getValue());
                            }
                        }
                    }
                }
            }
        }
    }
}
